<template>
  <div id="app">
    <div class="header">
      <el-menu
        :default-active="activeIndex2"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
        background-color="#373d41"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <div class="header-left">
          <img src="@/assets/logo2.png" alt="" />
          <span>杭州9期后台管理系统</span>
        </div>
        <el-button class="backbtn" @click="BackBtn">退出</el-button>
      </el-menu>
    </div>
    <div class="NavMenu">
      <el-container>
        <el-aside width="200px">
          <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
            <el-radio-button :label="false">展开</el-radio-button>
            <el-radio-button :label="true">收起</el-radio-button>
          </el-radio-group>
          <el-menu
            default-active="1-4-1"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            :collapse="isCollapse"
            background-color="#373d41"
            text-color="#fff"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-s-custom"></i>
                <span slot="title">用户管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="1-1">
                  <i class="el-icon-s-custom"></i>用户列表
                </el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-menu"></i>
                <span slot="title">权限管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="2-1">
                  <i class="el-icon-menu"></i>
                  角色列表</el-menu-item
                >
                <el-menu-item index="2-2">
                  <i class="el-icon-menu"></i>
                  权限列表</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-s-claim"></i>
                <span slot="title">商品管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="3-1">
                  <i class="el-icon-menu"></i>
                  商品列表</el-menu-item
                >
                <el-menu-item index="3-2">
                  <i class="el-icon-menu"></i>
                  分类参数</el-menu-item
                >
                <el-menu-item index="3-3">
                  <i class="el-icon-menu"></i>
                  商品分类</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-s-order"></i>
                <span slot="title">订单管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="4-1">
                  <i class="el-icon-menu"></i>
                  订单列表</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-s-marketing"></i>
                <span slot="title">数据统计</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="5-1">
                  <i class="el-icon-s-marketing"></i>
                  <span slot="title">数据报表</span></el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
          </el-menu></el-aside
        >
        <el-main>ABCD</el-main>
      </el-container>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      activeIndex: '1',
      activeIndex2: '1',
      isCollapse: false
    }
  },
  methods: {
    handleSelect (key, keyPath) {
      console.log(key, keyPath)
    },
    BackBtn () {
      // this.$router.push('/login')

      this.$confirm('此操作将退出登录, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '退出成功!'
          })
          this.$router.push('/login')
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          })
        })
    },
    handleOpen (key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose (key, keyPath) {
      console.log(key, keyPath)
    }
  }
}
</script>

<style scoped lang="less">
.header {
  .el-menu--horizontal {
    border-bottom: none !important;
  }
  .el-menu {
    padding: 0 20px;
    height: 60px;
    // box-sizing: border-box;
    // justify-content: space-between;
    // background-color: #373d41;
    .header-left {
      float: left;
      display: flex;
      -webkit-box-align: center;
      -ms-flex-align: center;
      align-items: center;
      img {
        display: inline-block;
      }
      span {
        font-size: 25px;
        color: #fff;
        margin-left: 8px;
      }
    }
    .backbtn {
      display: inline-block;
      line-height: 1;
      white-space: nowrap;
      cursor: pointer;
      background: #fff;
      border: 1px solid #dcdfe6;
      color: #606266;
      -webkit-appearance: none;
      text-align: center;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      outline: 0;
      margin: 0;
      -webkit-transition: 0.1s;
      transition: 0.1s;
      font-weight: 500;
      padding: 12px 20px;
      font-size: 14px;
      border-radius: 4px;
      float: right;
      // margin-to/p;
      margin-top: 10px;
    }
  }
}

.NavMenu {
  width: 100%;
  height: 100%;
  .el-container {
    height: 100%;
    .el-aside {
      overflow: hidden;

      .el-radio-group {
        margin-bottom: 0 !important;
      }
    }
  }
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    // width: 200px;
    height: 100%;
    overflow: hidden;
  }
}
</style>
